﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DataConcept.Entities;

namespace DataConcept.Business
{
    public class bl_Context
    {
        da_ConceptEntities db = new da_ConceptEntities();

        public Guid Create(Guid sceneId, Guid conceptId, string value, byte status)
        {
            var contextId = Guid.NewGuid();
            var result = (int)db.da_Context_New(
                contextId,
                sceneId,
                conceptId,
                value,
                status).Single();

            if (result > 0)
                return contextId;
            else
                return Guid.Empty;
        }
        public int Update(Guid contextId, string value, byte status)
        {
            var result = (int)db.da_Context_Update(
                contextId,
                value,
                status).Single();

            return result;
        }
        public int Delete(Guid contextId)
        {
            var result = (int)db.da_Context_Delete(
                contextId).Single();

            return result;
        }

        public List<da_Context> GetByConceptId(Guid conceptId)
        {
            var result = db.da_Context_GetbyConceptId(
                conceptId).ToList();

            return result;
        }
        public List<da_Context> GetBySceneId(Guid sceneId)
        {
            var result = db.da_Context_GetbySceneId(
                sceneId).ToList();

            return result;
        }
        public da_Context GetById(Guid contextId)
        {
            var result = db.da_Context_GetbyId(
                contextId).ToList();

            if (result.Count > 0)
                return result.First();
            else
                return null;
        }
        public List<da_Context> GetAll()
        {
            var result = db.da_Context.ToList();

            return result;
        }
    }
}
